<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .active{
            background: red;
        }
    </style>
</head>
<body>
    <p id="p">hello world</p>
    <button id="btn">addClass</button>
    <button  id="remove">removeClass</button>
    <button id="toggle">toggleClass</button>
    <!-- classList
         add()
         remove()
         toggle()
         contains()
    -->
    <script>
        var btn=document.getElementById("btn");
        var p=document.getElementById("p");
        var remove=document.getElementById("remove");
        var toggle=document.getElementById("toggle");
        btn.onclick=function(){
            p.classList.add("active")
        }
        remove.onclick=function(){
            p.classList.remove("active")
        }
        toggle.onclick=function(){
            p.classList.toggle("active")
        }
    </script>
</body>
</html>